<template>
  <div>
    <div > <van-icon name="arrow-left" @click="goBack" /> </div>
    <h2>欢迎您成为2211的会员</h2>
    <p>
        手机号码：<input type="text" v-model="username" />
    </p>
    <p>
        密码：<input type="password" v-model="userpass" />
    </p>
    <p>
        确认密码：<input type="password" v-model="userpass2" />
    </p>
    <p>
        <input type="button" value="注册" @click="regSave">
    </p>
    <div>{{msg}}</div>
  </div>
</template>

<script>
import axios from "axios";
import { Toast } from 'vant';

export default {
    name:"Reg",
    data(){
        return {
            username:"18991274261",
            userpass:"123666",
            userpass2:"123666",
            msg:""
        }
    },
    created(){
        console.log("Reg:this.$route.query",this.$route.query);
        this.getRandomCode();
    },
    methods:{
        goBack(){
            this.$router.back();
        },
        
        // 产生随机验证码
        getRandomCode(){
            let str = "";
            for(let i=0;i<4;i++){
                str += parseInt(Math.random()*10);
            }
            // this.randomCode = str;
        },
        // 注册
        regSave(){
            this.msg="";
            this.$service({
                method:"post",
                url:"/api/user/dofinishregister",
                data:`tel=${this.username}&password=${this.userpass}`
            })
            .then(res=>{
                if(res.data.code==200){
                    Toast("注册成功！");
                    this.$router.push("/Login");
                }
            });
         
        }
    }

}
</script>

<style>

</style>